home *** CD-ROM | disk | FTP | other *** search
Wrap
<!-- #include file="i_utils.asp" --> <% check_security(1) %> <% dim receipt_text dim success dim DateAdded dim LinkID dim user_id dim Title dim URL dim CatID dim LinkTypeID dim Description dim DownloadURL dim DownloadFee dim Email dim SUBMIT dim add_link_sql sub request_add_link ''' request expected input parameters for this form DateAdded = request("DateAdded") LinkID = request("LinkID") user_id = request("user_id") Title = request("Title") URL = request("URL") CatID = request("CatID") LinkTypeID = request("LinkTypeID") Description = request("Description") DownloadURL = request("DownloadURL") DownloadFee = request("DownloadFee") Email = request("Email") SUBMIT = request("SUBMIT") end sub sub validate_add_link ''' request and validate data entered from this form DateAdded = trim(request("DateAdded")) if DateAdded = "" then error_list.add "484202","DateAdded must be specified." b_error = true end if if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "484202date","DateAdded must be a valid date (MM/DD/YY)." b_error = true end if LinkID = trim(request("LinkID")) user_id = trim(request("user_id")) if user_id = "" then error_list.add "484212","user_id must be specified." b_error = true end if Title = trim(request("Title")) if Title = "" then error_list.add "484210","Site Title must be specified." b_error = true end if URL = trim(request("URL")) if URL = "" then error_list.add "484211","URL must be specified." b_error = true end if CatID = trim(request("CatID")) if CatID = "" then error_list.add "484213","Category must be specified." b_error = true end if LinkTypeID = trim(request("LinkTypeID")) if LinkTypeID = "" then error_list.add "484208","Resource Type must be specified." b_error = true end if Description = trim(request("Description")) if Description = "" then error_list.add "484203","Description must be specified." b_error = true end if DownloadURL = trim(request("DownloadURL")) DownloadFee = trim(request("DownloadFee")) Email = trim(request("Email")) if Email = "" then error_list.add "484206","Email must be specified." b_error = true end if SUBMIT = trim(request("SUBMIT")) end sub sub get_defaults_add_link ''' set default values for this form DateAdded = "" & now() & "" user_id = session("user_id") SUBMIT = "SUBMIT" end sub sub db_select_add_link sql = "SELECT " & _ "DateAdded, " & _ "LinkID, " & _ "user_id, " & _ "Title, " & _ "URL, " & _ "CatID, " & _ "LinkTypeID, " & _ "Description, " & _ "DownloadURL, " & _ "DownloadFee, " & _ "Email FROM Links" & _ " WHERE " & _ "Links.LinkID = " & to_sql(LinkID,"number") & "" on error resume next set rs = cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "select_data_add_link", "The data selection failed. " & err.description elseif rs.EOF then b_results = false msg_list.add "select_data_add_link", "The record was removed from the database." else DateAdded = rs("DateAdded") LinkID = rs("LinkID") user_id = rs("user_id") Title = rs("Title") URL = rs("URL") CatID = rs("CatID") LinkTypeID = rs("LinkTypeID") Description = rs("Description") DownloadURL = rs("DownloadURL") DownloadFee = rs("DownloadFee") Email = rs("Email") SUBMIT = rs("SUBMIT") end if rs.Close on error goto 0 end sub sub db_insert_add_link sql = "INSERT INTO Links" & _ "(" & _ "CatID," & _ "DateAdded," & _ "Description," & _ "DownloadFee," & _ "DownloadURL," & _ "Email," & _ "LinkTypeID," & _ "Title," & _ "URL," & _ "display," & _ "user_id" & _ ") VALUES (" & _ "" & to_sql(CatID,"number") & "," & _ "" & to_sql(DateAdded,"text") & "," & _ "" & to_sql(Description,"text") & "," & _ "" & to_sql(DownloadFee,"text") & "," & _ "" & to_sql(DownloadURL,"text") & "," & _ "" & to_sql(Email,"text") & "," & _ "" & to_sql(LinkTypeID,"number") & "," & _ "" & to_sql(Title,"text") & "," & _ "" & to_sql(URL,"text") & "," & _ "0," & _ "" & to_sql(user_id,"number") & ")" & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.Number <> 0 then b_error = true error_list.add "db_insert_add_link" & err.Number ,"The database insert failed. " & err.Description else set rs = cn.Execute("SELECT @@IDENTITY") LinkID = rs(0) rs.Close msg_list.add "db_insert_add_link","The database insert was successful." end if on error goto 0 end sub sub db_update_add_link sql = "UPDATE Links SET " & _ "DateAdded = " & to_sql(DateAdded,"text") & ", " & _ "user_id = " & to_sql(user_id,"number") & ", " & _ "Title = " & to_sql(Title,"text") & ", " & _ "URL = " & to_sql(URL,"text") & ", " & _ "CatID = " & to_sql(CatID,"number") & ", " & _ "LinkTypeID = " & to_sql(LinkTypeID,"number") & ", " & _ "Description = " & to_sql(Description,"text") & ", " & _ "DownloadURL = " & to_sql(DownloadURL,"text") & ", " & _ "DownloadFee = " & to_sql(DownloadFee,"text") & ", " & _ "Email = " & to_sql(Email,"text") & " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true error_list.add "db_update_add_link" & err.Number ,"The database update failed. " & err.Description else msg_list.add "db_update_add_link" & LinkID,"The database update was successful." end if on error goto 0 end sub sub db_delete_add_link sql = "DELETE FROM Links" & _ " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "db_delete_add_link" & err.Number ,"The database deletion failed. " & err.Description else msg_list.add "db_delete_add_link","The record was removed." end if on error goto 0 end sub do_search = request("do_search") ''' request form keys receipt_text = request("receipt_text") success = request("success") LinkID = request("LinkID") ''' request action action = lcase(request("action")) ''' action case handler select case action case "select_add_link" ' select the requested key record from database if LinkID <> "" then db_select_add_link else b_error = true error_list.add "edit_add_link", "Specify record to select." end if case "insert_add_link" ' request form data and insert a new record into database validate_add_link if not b_error then db_insert_add_link if not b_error then response.redirect "submit.asp?success=1" end if case "update_add_link" ' request form data and update an existing database record validate_add_link if not b_error then if LinkID <> "" then db_update_add_link else b_error = true error_list.add "update_add_link", "Specify record to update." end if end if case "delete_add_link" ' delete the requested key database record if LinkID <> "" then db_delete_add_link response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_add_link", "Specify record to delete." end if end select ' no action was specified, so handle the default case(s) if receipt_text <> "" AND success <> "" then db_select_receipt_text end if if LinkID <> "" then db_select_add_link else get_defaults_add_link end if %> <!-- #include file='i_header.asp' --> <!-- #include file='i_menu.asp' --> <% display_errs display_msg %> <% if success = 1 then %> <!-- display receipt text --> <ul> Thanks for submitting your site. It will be reviewed for inclusion in our links section. </ul> <% else %> <!-- display the submit form --> <% CatId = request("CatId") %> <table class='headerTable'> <tr> <td class='headerTD'> Suggest your site </td> </tr> </table> <table style={width:'100%';}> <form name="add_link" action="submit.asp" method="post" > <input type=hidden name="DateAdded" value="<% =DateAdded %>"> <input type=hidden name="LinkID" value="<% =LinkID %>"> <input type=hidden name="user_id" value="<% =user_id %>"> <tr> <td class='labelTD'>Site Title</td> <td class='dataTD' > <input type=text name="Title" size="" maxlength="60" value="<% =Title%>"> </td> <td class='labelTD'></td> </tr> <tr> <td class='labelTD'>URL</td> <td class='dataTD' > <input type=text name="URL" size="" maxlength="100" value="<% =URL%>"> </td> <td class='labelTD'></td> </tr> <tr> <td class='labelTD'>Category</td> <td class='dataTD' > <select name="CatID" > <option></option> <% =get_options ("SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId = Cats2.CatId) left JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId) WHERE Cats.ParentId is NULL order by (Cats.Cat + Cats1.Cat + Cats2.Cat + Cats3.Cat)", CatID) %> </select> </td> <td class='labelTD'></td> </tr> <tr> <td class='labelTD'>Resource Type</td> <td class='dataTD' > <select name="LinkTypeID" > <% =get_options ("SELECT LinkTypeID, LinkType FROM LinkTypes", LinkTypeID) %> </select> </td> <td class='labelTD'></td> </tr> <tr> <td class='labelTD'>Description</td> <td class='dataTD' > <textarea name="Description" rows='5' cols='60'><% =Description%></textarea> </td> <td class='labelTD'>upto 100 words - no HTML!</td> </tr> <tr> <td class='labelTD'>Download URL</td> <td class='dataTD' > <input type=text name="DownloadURL" size="" maxlength="100" value="<% =DownloadURL%>"> </td> <td class='labelTD'>if you product is downloadable, specify the download url</td> </tr> <tr> <td class='labelTD'>Minimum Cost/Fee</td> <td class='dataTD' > <input type=text name="DownloadFee" size="" maxlength="40" value="<% =DownloadFee%>"> </td> <td class='labelTD'>if you sell products or services on your site, what is the minimum cost?</td> </tr> <tr> <td class='labelTD'>Email</td> <td class='dataTD' > <input type=text name="Email" size="" maxlength="50" value="<% =Email%>"> </td> <td class='labelTD'>used for aspapp.com internal use only</td> </tr> <tr> <td class='labelTD'></td> <td class='dataTD' > <input class=cmd type=submit name="SUBMIT" value="SUBMIT" > </td> <td class='labelTD'></td> </tr> <tr> <td class=labelTD align=right> <% if LinkID <> "" then %><% end if %> </td> <td class=dataTD> <% if LinkID = "" then %><% end if %> </td> <td class=labelTD> </td> <input type=hidden name="action" value="<% if LinkID <> "" then %>update<% else %>insert<%end if %>_add_link"></tr> </form> </table> <% end if %> <!-- #include file=i_footer.asp --> <% ':: assure that any db resources are freed on error resume next rs.Close set rs = NOTHING cn.Close set cn = NOTHING user_cn.Close set user_cn = NOTHING on error goto 0 %>